<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php include 'inc/head.php'; ?>
</head>

<body>
  <?php include 'inc/header.php'; ?>

  <div class="container">

    <table class="table table-sm table-bordered table-hover">
      <thead class="bg-light">
        <tr>
          <th>角色名称</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <?php
        foreach ($list as $row) {
          echo '<tr><td>' . $row['r_name'] . '</td><td>' . ($row['id'] != 1 ? ($row['r_priv'] != 'all' ? '<a href="' . M('admin', 'role', 'edit', $row['id']) . '">编辑</a> ' : '') . '<a href="' . M('admin', 'role', 'del', $row['id']) . '" onclick="return confirm(\'确认要删除吗？\')">删除</a>' : '') . '</td></tr>';
        }
        ?>
      </tbody>
    </table>


    <?php
    echo form_create(
      ['action' => M('admin', 'role', 'add')],
      [
        ['type' => 'part_start'],
        ['type' => 'text', 'label' => '名称', 'key' => 'r_name', 'required' => 'required'],
        [
          'type' => 'select',
          'label' => '超管权限', 'key' => 'r_priv', 'value' => [['label' => '不选择', 'value' => ''], ['label' => '赋予超管权限', 'value' => 'all']]
        ],
        ['type' => 'part_end'],
        ['type' => 'submit', 'label' => '提交', 'key' => 'save']
      ],
      ['角色新增']
    );
    ?>

  </div>

  <?php include 'inc/footer.php'; ?>

</body>

</html>